package com.lee.day01;

import com.lee.channel.InputChannel;
import com.lee.model.OrderModel;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2022/8/25
 */
//@Service
public class Consumer {

    @StreamListener(target = InputChannel.order_input)
    public void orderHandler01(@Payload OrderModel orderModel) {
        System.out.println("From rabbitmq OrderModel: " + orderModel);
    }

    /**
     * 如果两个方法指定了同样的target, 那么就能消费到重复的消息.
     * @param orderModel
     */
//    @StreamListener(target = InputChannel.order_input)
//    public void orderHandler01_dup(@Payload OrderModel orderModel) {
//        System.out.println("rabbitmq: " + orderModel);
//    }

    @StreamListener(target = InputChannel.order_input_2)
    public void orderHandler02(@Payload OrderModel orderModel) {
        System.out.println("From Rabbitmq: OrderModel_2: " + orderModel);
    }


    @StreamListener(target = InputChannel.oa_input)
    public void oaHandler01(@Payload OrderModel orderModel) {
        System.out.println("From kafka: OrderModel: " + orderModel);
    }

    @StreamListener(target = InputChannel.oa_input_2)
    public void oaHandler02(@Payload OrderModel orderModel) {
        System.out.println("From kafka: OrderModel_2: " + orderModel);
    }
}
